import WebStorageCache from 'web-storage-cache'

class CacheClass {
  constructor (type) {
    this.storage = new WebStorageCache({storage: type})
  }

  set (key, value, exp) {
    const options = exp ? {exp: exp} : null
    this.storage.set(key, value, options)
  }

  get (key) {
    return this.storage.get(key)
  }

  delete (key) {
    this.storage.delete(key)
  }
}

export const lsStorage = new CacheClass('localStorage');
export const ssStorage = new CacheClass('sessionStorage');
